# Django settings for ocms project.
import logging
import os, os.path

# Load the local settings
from local_settings import *

MANAGERS = ADMINS

#UTF-8 is required
DATABASES['default']['OPTIONS'] = {
   'init_command' : 'SET NAMES "utf8"',
   }

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/admin_media/'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    
    #satchmo includes
    "django.middleware.locale.LocaleMiddleware",
    "django.middleware.doc.XViewMiddleware",
    "threaded_multihost.middleware.ThreadLocalMiddleware",
    "satchmo_store.shop.SSLMiddleware.SSLRedirect",
)

ROOT_URLCONF = 'ocms.urls'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    '/opt/web/django/ocms/TEMPLATES', #need to change in production
)

#formatting
#DATE_FORMAT = 'Y-m-d'
#DATETIME_FORMAT = ''

#required for the registration system
ACCOUNT_ACTIVATION_DAYS = 7

#it is important for ocms.accounts to come first
INSTALLED_APPS = (
    'ocms.accounts',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'ocms.eventmanager',
    'ocms.main',
    'django.contrib.admin',
    'ocms.registration',
    'ocms.ocms_comments',
    'django.contrib.comments',
    'django_evolution',
#    'django_cron',

#satchmo Stuff
    'django.contrib.sites',
    'satchmo_store.shop',
    'django.contrib.admindocs',
    'django.contrib.auth',
    'django.contrib.sitemaps',
    'sorl.thumbnail',
    'keyedcache',
    'livesettings',
    'l10n',
    'satchmo_utils.thumbnail',
    'satchmo_store.contact',
    'tax',
    'tax.modules.no',
    'tax.modules.area',
    'tax.modules.percent',
    'shipping',
    'shipping.modules.ups',
    #'shipping.modules.per',
    #'satchmo_store.contact.supplier',
    #'shipping.modules.tiered',
    #'satchmo_ext.newsletter',
    #'satchmo_ext.recentlist',
    #'testimonials',         # dependency on  http://www.assembla.com/spaces/django-testimonials/
    'product',
    'product.modules.configurable',
    'product.modules.custom',
    #'product.modules.downloadable',
    #'product.modules.subscription',
    #'satchmo_ext.product_feeds',
    #'satchmo_ext.brand',
    'payment',
    #'payment.modules.dummy',
    #'payment.modules.purchaseorder',
    'ocms.merch.owasp_payments',
    #'payment.modules.giftcertificate',
    #'satchmo_ext.wishlist',
    #'satchmo_ext.upsell',
    'satchmo_ext.productratings',
    'satchmo_ext.satchmo_toolbar',
    'satchmo_utils',
    #'shipping.modules.tieredquantity',
    #'satchmo_ext.tieredpricing',
    #'typogrify',            # dependency on  http://code.google.com/p/typogrify/
    #'debug_toolbar',
    'app_plugins',

)

#allows custom request template context processors
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.contrib.messages.context_processors.messages",
"ocms.context_processors.settings_site_url_root_processor",

#satchmo stuff
'satchmo_store.shop.context_processors.settings',)

#Auth backend allowing username/email interchangability
AUTHENTICATION_BACKENDS = (
    'ocms.registration.email-auth.EmailBackend',
 )
AUTHENTICATION_BACKENDS = (
    'satchmo_store.accounts.email-auth.EmailBackend',
    'django.contrib.auth.backends.ModelBackend',
)

#Comment customization
COMMENTS_APP = 'ocms.ocms_comments'

#login redirect
LOGIN_REDIRECT_URL = '/events'

#### Satchmo unique variables ####
#from django.conf.urls.defaults import patterns, include
SATCHMO_SETTINGS = {
                    'SHOP_BASE' : '',
                    'MULTISHOP' : False,
                    'SSL'       : False,
                    #'SHOP_URLS' : patterns('satchmo_store.shop.views',)
                    }

SKIP_SOUTH_TESTS=True

# Load the local settings
#from local_settings import *

#Configure logging
LOGFILE = "ocms.log"
logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                    datefmt='%a, %d %b %Y %H:%M:%S',
                    filename='/opt/web/django/ocms/ocms.log',
                    filemode='w')

logging.getLogger('keyedcache').setLevel(logging.INFO)
logging.getLogger('l10n').setLevel(logging.INFO)
logging.info("ocms Started")
